class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2021-08-04",
      revision: "d47bcea78dd412c6f8f6ed8d51a2a1b9f3b71f30"
  version "2021-08-04"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_big_sur: "91c6b9f8e9d3fc6f54d6745390e8303d2fb2bdf05c7f888d6da91427206091ab"
    sha256 cellar: :any_skip_relocation, big_sur:       "7852202753bbb59a1f9168050d265445d6566b9a136d45920e175f5e9d2f8c6f"
    sha256 cellar: :any_skip_relocation, catalina:      "e19ab6113aa81a6370d9acdf1502d7bd2b4c32d98f01ceab1cfd4059cdecdc35"
    sha256 cellar: :any_skip_relocation, mojave:        "93946d3a569ba3f967a0d888c6f9319876db44a60410f130589a657a14ceaa1d"
    sha256 cellar: :any_skip_relocation, x86_64_linux:  "adef79ff2f231fb41a55f0790775d370a9e132abf923aa0a09e243cccc4df2e0"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
